'use strict';

module.exports = app => {
  const { router, controller: { house }, middleware: { validator, checkPageTable, checkParams } } = app;

  const baseUrl = '/api/house';
  router.get(baseUrl + '/my', checkPageTable(), house.indexMy);
  router.get(baseUrl + '/shops', checkPageTable(), house.indexShops);
  router.get(baseUrl + '/shops/:id', checkParams(), house.showShops);
  router.get(baseUrl + '/examine', checkPageTable(), house.indexExamine);
  router.get(baseUrl + '/allMy', house.allMy);
  router.get(baseUrl + '/all', house.indexAll);
  router.patch(baseUrl + '/agree', validator('common.checkId'), house.agree);
  router.patch(baseUrl + '/disagree', validator('common.checkId'), house.disagree);
  router.patch(baseUrl + '/grounding', validator('common.checkId'), house.grounding);
  router.patch(baseUrl + '/undercarriage', validator('common.checkId'), house.undercarriage);
  router.get(baseUrl + '/statisticalHouse', house.statisticalHouse);
  router.get(baseUrl + '/statisticalHouseAll', house.statisticalHouseAll);
  router.get(baseUrl + '/statisticalViews', house.statisticalViews);
  router.get(baseUrl + '/statisticalViewsAll', house.statisticalViewsAll);
  router.get(baseUrl + '/statisticalHouseAdd', house.statisticalHouseAdd);
  router.get(baseUrl + '/viewsRank', house.indexViewsRank);
  router.get(baseUrl + '/like', house.indexLike);
  router.get(baseUrl + '/hot', house.indexHouseHot);
  router.get(baseUrl, checkPageTable(), house.index);
  router.get(baseUrl + '/:id', checkParams(), house.show);
  router.post(baseUrl, validator('house.create'), house.create);
  router.put(baseUrl + '/:id', checkParams(), validator('house.update'), house.update);
  router.delete(baseUrl + '/:id', checkParams(), house.destroy);
};
